<template>
	<view class="me-box">
		<TopBar :indexflag="true" :combakflag="false" :lang="false" :bottom="true" :title="$t('Me')"
			barstyle="#fff" Color="#000"></TopBar>
		<view class="me-header">
			<view class="user-box">
				<view class="avartar">
					<image :src="userInfo.avatar" mode=""></image>
				</view>
				<view class="username">{{userInfo.username}}</view>
			</view>
		</view>
		<view class="menu-box">
			<view class="top-menu">
				<view class="item" v-for="(item,index) in top_menu" @click="changemenu(item.url)">
					<text class="item-title">{{$t(item.name)}}</text>
					<text class="number">12</text>
					
				</view>
			</view>
			<view class="footer-menu">
				<view class="item" style="justify-content: space-around;">
					<view class="title" @click="changeWork(true)">
						<u-icon name="rmb-circle-fill" :color="work?'#45BC1B':'#a7a7a7'" size="26"></u-icon>
						<text>{{$t('Work')}}</text>
					</view>
					<view class="title" @click="changeWork(false)">
						<u-icon name="hourglass-half-fill" :color="work?'#a7a7a7':'#d81e06'" size="26"></u-icon>
						<text>{{$t('Rest')}}</text>
					</view>
				</view>
				<view class="item" style="justify-content: space-around;padding: 10rpx 0rpx;">
					<view class="title" v-if="work" style="color:#45BC1B" >
						<text :dir="i18nLocale=='ug'?'rtl':''" >{{$t('WorkContent')}}</text>
					</view>
					<view class="title"  v-if="!work" style="color:#d81e06">
						<text :dir="i18nLocale=='ug'?'rtl':''" >{{$t('RestContent')}}</text>
					</view>
				</view>
				<view class="item">
					<view class="title">
						<u-icon name="volume" color="#45BC1B" size="26"></u-icon>
						<text :dir="i18nLocale=='ug'?'rtl':''"  >{{$t('Voice')}}</text>
					</view>
					
						<u-switch v-model="voice" @change="change"  activeColor="#45bc1b"  ></u-switch>
				
				</view>
				<view class="item" v-for="(item,index) in footer_menu" @click="changemenu(item.url,index)">
					<view class="title">
						<u-icon :name="item.icon" color="#45BC1B" size="26"></u-icon>
						<text>{{$t(item.name)}}</text>
					</view>
					<view class="icon-box">
						<u-icon name="arrow-right" color="#fff" size="16"></u-icon>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import TopBar from "@/components/TopBar.vue"
	import HeaderTitle from "@/components/HeaderTitle.vue"
	import {workstatus} from '@/api/all.js';
	
	export default {
		components: {
			TopBar,
			HeaderTitle
		},
		data() {
			return {
				voice:true,
				work:this.$store.state.riderinfo.status,
				top_menu: [
					{
							name: 'Order',
							icon: 'order',
							url: '/pages/me/meorder'
						},
						{
							name: 'Revenue',
							icon: 'account',
							url: '/pages/me/merevenue'
						},
						{
							name: 'MyComment',
							icon: 'integral',
							url: '/pages/me/mecomment'
						}
				],
				footer_menu: [
					{
						name: 'Headquarters',
						icon: 'phone',
						url: ''
					},
					{
						name: 'AboutUs',
						icon: 'error-circle',
						url: ''
					},
					// {
					// 	name: 'ChangePassword',
					// 	icon: 'eye',
					// 	url: ''
					// }
				]
			}
		},
		onShow() {
			uni.hideTabBar({
				animation: false
			})

		},
		computed: {
			i18nLocale() {
				return this.$i18n.locale;
			},
			userInfo(){
			
				return this.$store.state.riderinfo;
			}
			
		},
		mounted() {
			// this.translationAlign('zh','深圳城','uy');
			
		},
		methods: {
			changemenu(url, index) {
				if (url) {
					uni.navigateTo({
						url: url
					})
				} else {
				
					if (index == 0) {
						this.changeMobile('17690927591')
					}else if(index == 2){
						uni.navigateTo({
							url:'/pages/me/deliveryperson'
						})
					}else{
						uni.showToast({
							title: '待开发 !',
							icon: "none",
							duration: 3000,
						
						})
					}

				}
				

			},
			change(e) {
				this.voice=e;
			},
			changeMobile(mobile) {
				uni.makePhoneCall({
					phoneNumber: mobile
				})

			},
			changeWork(flag){
				workstatus({
					status:flag?1:0
				}).then((res)=>{
					if(res.code==200){}
				})
				this.work=flag;
			}

		}
	}
</script>

<style lang="scss" scoped>
	.me-box {
		width: 100%;
		height:100%;
		padding-bottom: 300rpx;

		.me-header {
			width: 100%;
			height: 330rpx;
			display: flex;
			justify-content: center;
			// align-items: center;
			border-radius: 10rpx 10rpx 10rpx 10rpx;
			background: url('https://img.tukuppt.com/bg_grid/00/09/54/jqatRwQB9X.jpg!/fh/350');
			background-size: 100% 100%;
			background-repeat: no-repeat;
			.user-box {
				display: flex;
				flex-direction: column;
				align-items: center;
				margin-top: 50rpx;

				.avartar {
					width: 120rpx;
					height: 120rpx;
					border-radius: 100%;
					background-color: rgba(0, 0, 0, 0.2);

					image {
						width: 100%;
						height: 100%;
						border-radius: 100%;
					}
				}

				.username {
					color: #fff;
					font-size: $uni-font-size-lg;
					margin-top: $uni-spacing-margin-sm;
				}
			}
		}

		.menu-box {
			width: 100%;
			padding: 0rpx 30rpx;
			margin-top: -70rpx;
			box-sizing: border-box;

			.top-menu {
				width: 100%;
				display: flex;
				justify-content: space-around;
				align-items: center;
				background-color: #fff;
				border-radius: $uni-border-radius-lg;
				padding: 40rpx $uni-spacing-padding-sm;
				box-sizing: border-box;
				color: $uni-color-title;
				font-size: $uni-font-size-sm1 ;
				box-shadow: $uni-bg-shadow;
				font-weight: 500;

				.item {
					display: flex;
					flex-direction: column;
					align-items: center;

					.icon {}
					.number{
						color:$uni-color-topic;
						font-size: $uni-font-size-lg;
						padding-top: 10rpx;
					}
					.item-title {
						padding-top: 10rpx;
						padding-bottom: 10rpx;
					}
				}
			}

			.footer-menu {
				width: 100%;
				box-sizing: border-box;
				margin-top: 30rpx;

				.item {
					display: flex;
					justify-content: space-between;
					align-items: center;
					box-sizing: border-box;
					padding: 30rpx 20rpx;
					// border-bottom: 1rpx solid $uni-border-color;
					color: $uni-color-title;
					font-size: $uni-font-size-sm1 ;
					border-radius: $uni-border-radius-lg;
					margin-top: $uni-spacing-margin-sm;
					background-color: $uni-text-color-inverse;
					box-shadow: $uni-bg-shadow;
					font-weight: 500;

					.title {
						display: flex;
						align-items: center;

						text {
							padding: 0rpx 20rpx;

						}
					}

					.icon-box {
						padding: 15rpx;
						background-color: $uni-color-topic;
						box-shadow: $uni-bg-shadow;
						border-radius: $uni-border-radius-base;

					}
				}
			}
		}
	}
</style>